package com.website.quartz.control;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.website.common.vo.Page;
import com.website.common.vo.Result;
import com.website.mybatis.entity.Quartz;
import com.website.quartz.service.QuartzTimerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("admin/quartz")
public class QuartzController {

    @Autowired
    QuartzTimerService mgr;

    @RequestMapping("getList")
    @ResponseBody
    public Page<Quartz> getList(Quartz model, Page<Quartz> page){
        IPage<Quartz> p = mgr.getPage(model, page.getPage(), page.getLimit());
        page.setCount(p.getTotal());
        page.setData(p.getRecords());
        return page;
    }
    @RequestMapping("del")
    @ResponseBody
    public Result del(Long id){
        return mgr.del(id);
    }
    @RequestMapping("save")
    @ResponseBody
    public Result add(Quartz model){
        return mgr.add(model);
    }
    @RequestMapping("start")
    @ResponseBody
    public Result start(Long id){
        return mgr.updStart(id);
    }
    @RequestMapping("stop")
    @ResponseBody
    public Result stop(Long id){
        return mgr.updStop(id);
    }
    @RequestMapping("update")
    @ResponseBody
    public Result update(Quartz model){
        return mgr.update(model);
    }

}
